//
//  LSRTextField.m
//  BaiSiProject
//
//  Created by lshenrong on 16/7/9.
//  Copyright © 2016年 lshenrong. All rights reserved.
//

#import "LSRTextField.h"
//#import "UITextField+placeholderColor.h"

#import "UITextField+placeholderColor.h"

@implementation LSRTextField

-(void)awakeFromNib
{

    [super awakeFromNib];
    
    //设置光标的颜色
    self.tintColor=[UIColor whiteColor];
    //设置占位字符的颜色
  
    self.placeholderColor=[UIColor lightGrayColor];
//
//    NSMutableDictionary *attDict=[NSMutableDictionary dictionary];
//    attDict[NSForegroundColorAttributeName]=[UIColor lightGrayColor];
//    //是self.placeholder不是self.text
//    NSAttributedString *attrString=[[NSAttributedString alloc] initWithString:self.placeholder attributes:attDict];
//    self.attributedPlaceholder=attrString;
    //监听文本框的编辑状态改变
    [self addTarget:self action:@selector(textBegin) forControlEvents:UIControlEventEditingDidBegin];
     [self addTarget:self action:@selector(textEnd) forControlEvents:UIControlEventEditingDidEnd];

}

//开始编辑
-(void)textBegin
{
//    NSMutableDictionary *attDict=[NSMutableDictionary dictionary];
//    attDict[NSForegroundColorAttributeName]=[UIColor whiteColor];
//    //是self.placeholder不是self.text
//    NSAttributedString *attrString=[[NSAttributedString alloc] initWithString:self.placeholder attributes:attDict];
//    self.attributedPlaceholder=attrString;
//
    self.placeholderColor=[UIColor whiteColor];

}
//停止编辑
-(void)textEnd
{
//    NSMutableDictionary *attDict=[NSMutableDictionary dictionary];
//    attDict[NSForegroundColorAttributeName]=[UIColor lightGrayColor];
//    //是self.placeholder不是self.text
//    NSAttributedString *attrString=[[NSAttributedString alloc] initWithString:self.placeholder attributes:attDict];
//    self.attributedPlaceholder=attrString;

    self.placeholderColor=[UIColor lightGrayColor];

}




@end
